package com.cxria.sms.service.impl;

import com.cxria.sms.persistence.PersistenceException;
import com.cxria.sms.persistence.PersistenceService;

import java.util.Optional;
import java.util.ServiceLoader;

public class PersistenceServiceLoader {

    public static PersistenceService persistenceService;

    static {
        final Optional<PersistenceService> optionalService = ServiceLoader.load(PersistenceService.class).findFirst();
        if (optionalService.isPresent()){
            persistenceService = optionalService.get();
        } else {
            throw new RuntimeException("没有持久化服务!");
        }
    }

}
